// pages/selectGender/selectGender.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    gender: '',
    genders: [
      { label: '男', value: 'MALE' },
      { label: '女', value: 'FEMALE' },
      { label: '保密', value: 'SECRET' },
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (options.key) {
      this.setData({
        gender: options.key
      })
    }
  },

  setSex({ currentTarget }) {
    this.setData({ gender: currentTarget.dataset.val })
  },

  done(e) {
    const pages = getCurrentPages();
    let prevPage = pages[pages.length - 2];
    prevPage.setData({
      'form.sex': this.data.gender,
      sex: { MALE: '男', FEMALE: '女', SECRET: '保密' }[this.data.gender]
    })
    wx.navigateBack({
      delta: 1,
    })
  }

})
